clear
clear all
cap log close

log using "log-files/2_Figure_H4.smcl", replace smcl

timer on 2

*------------*
* Figure H.4 *
*------------*
	* Figure H.4.a
	*-------------
		import excel using "data/inputs/2_Peru2021Runoff.xlsx", clear

		keep B F I
		rename B actas_cont
		rename F ppnpl
		rename I fp

		drop if _n==1

		destring actas_cont ppnpl fp, replace

		gen margin_castillo=ppnpl-fp

		twoway (line margin_castillo actas_cont, lwidth(thick) lcolor(midblue)), ///
			graphregion(color(white)) xlabel(40(10)100) ylabel(,angle(0)) ///
			xtitle("Percentage of Tally Sheets Accounted For") ///
			ytitle("Perú Libre Margin") ///
			legend(off)	yline(0, lpattern(dash) lcolor(black))
		graph export "outputs/generated/Figure_H4a.pdf", replace

	* Figure H.4.b
	*-------------
		twoway (line fp actas_cont, lwidth(thick) lcolor(gs6)) ///
			(line ppnpl actas_cont, lwidth(thick) lcolor(midblue)), ///
			graphregion(color(white)) xlabel(40(10)100) ylabel(,angle(0)) ///
			xtitle("Percentage of Tally Sheets Accounted For") ///
			ytitle("Cumulative Vote Share") ///
			legend(cols(1) lab(1 "Fuerza Popular") lab(2 "Perú Libre") ///
				pos(1) ring(0))
		graph export "outputs/generated/Figure_H4b.pdf", replace

*------------------------------------------------------------------------------*
timer off 2
timer list 2

log close
clear all
